Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

196
Visualizações
how to sort this two sub array [ { [ ] } ,{ [ ] } , { [ ] } ,] in javascript

how can i sort this tests array based on discount_price i have sorted only the lab_partners array,,,can anyone tell me how to sort the main array nd so that array should look something like : 200 ,250, 299 ,500 so my array is something like this - [ { [ ] } ,{ [ ] } , { [ ] } ,]

"tests": [
 {
   "id": 11,
  "habit_test_id": 3,
  "test_id": 1,
  "test": {
           "id": 1,
            "test_name": "Blood Test",
          },
   "lab_partners": [
  {
     "id": 1,
    "discounted_price": 250, 
  },
  {
     "id": 7,
     "discounted_price": 299,

    }
   ]
 },
 {

 "test": {
     "id": 4,
     "test_name": "MRI",

      },
 "lab_partners": [
     {
    "id": 6,

   "discounted_price": 500,

  },
  {
    "id": 6,

   "discounted_price": 200,

  }
 ]
 }
]
}

//this only sort the lab_partners array i want to sort on the basis of both test array

 const condition_based=   tests.map((itr, idx) =>
  itr.lab_partners.sort((firstItem, secondItem) => ( firstItem.discounted_price - 
  secondItem.display_price)));
  console.log(condition_based,'condition_based');
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I don't really know what you are trying to achieve, or what you expect from this array, but please look into this

https://www.w3schools.com/JS/js_object_constructors.asp

It seems to me like there are some similarities in all the object values, and you are missing out some maybe just because they are null values.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda